<?php
/**
 * Created by PhpStorm.
 * User: zhoper
 * Date: 2018/7/28
 * Time: 16:14
 */
namespace app\models;

use Yii;
use yii\base\Model;

class UserForm extends Model
{
    public $username;
    public $password;
    /**
     * @return array the validation rules.
     */
    public function rules()
    {
        return [
            // username and password are both required
            [['username', 'password'], 'required'],
            // rememberMe must be a boolean value
        ];
    }

    public function login($datas)
    {
        foreach ($datas as $k => $v){
            if(property_exists($this, $k)){
                $this->{$k} = $v;
            }
        }
        return true;
    }
}